﻿#ifndef ___THREAD_SEND_POOL_H__
#define ___THREAD_SEND_POOL_H__

#include <vector>
#include "SendThread.h"
//线程池容器
class CSendThreadPool
{
public:
    
    CSendThreadPool();               
    
    ~CSendThreadPool();
private:
    int 						   m_ThreadObjNum;
	std::vector<CSendThread *>     m_ThreadVector;
public:
	//创建对象，开始工作
	bool Start(int ThreadObjNum);
	
	//停止工作，销毁对象
	void Stop();
	
	//添加任务到对象
	void    AddTask(int nID, char  *szTask);

    size_t SendProc(int nID, void *pClient,char  *data, int  nLen);

    void  SemPost(int  nID);
	static CSendThreadPool* GetObject();				//获取连接池对象

    static CSendThreadPool* GetInstance();

    class GC
    {
    public:
        ~GC()
        {
            if (pPoolObj != nullptr)
                delete pPoolObj;
        }
    };

    static CSendThreadPool* pPoolObj;
    static std::mutex               mutex_;
    static GC                           gc;
};
#endif
